﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.IO;
using System.Drawing;

namespace TznxStart
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            System.Configuration.ConfigurationManager.RefreshSection("appSettings");

            {
                string strName = Application.ExecutablePath;
                string strnewName = strName.Substring(strName.LastIndexOf("\\") + 1);
                if (System.Configuration.ConfigurationManager.AppSettings["AtuoRunWithSystem"].ToString() != "true")
                {
                    //修改注册表，使程序开机时不自动执行。  
                    Microsoft.Win32.RegistryKey Rkey = Microsoft.Win32.Registry.LocalMachine.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run");
                    Rkey.DeleteValue(strnewName, false);
                }
                else
                {
                    if (!File.Exists(strName))//指定文件是否存在  
                        return;
                    Microsoft.Win32.RegistryKey Rkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
                    if (Rkey == null)
                        Rkey = Microsoft.Win32.Registry.LocalMachine.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run");
                    Rkey.SetValue(strnewName, strName);//修改注册表，使程序开机时自动执行。  
                    //MessageBox.Show("程序设置完成，重新启动计算机后即可生效！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }

            //if (System.Configuration.ConfigurationManager.AppSettings["1024_Or_1280"].ToString() == "1024")
            //{
            //    Application.Run(new SmartDialog());
            //}
            //else if (System.Configuration.ConfigurationManager.AppSettings["1024_Or_1280"].ToString() == "1280")
            //{
            //    Application.Run(new BigDialog());
            //}
            //else
            //{
            //    MessageBox.Show("系统配置错误,没有支持的屏幕大小!");
            //    Application.Exit();
            //}
            Rectangle rect = System.Windows.Forms.SystemInformation.VirtualScreen;
            if (rect.Width == 1024 && rect.Height == 768)
            {
                Application.Run(new SmartDialog());
            }
            else
            {
                Application.Run(new BigDialog());
            }
        }
    }
}
